package pingan.com.quarter_hour.acyivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.facebook.drawee.view.SimpleDraweeView;
import com.leon.lib.settingview.LSettingItem;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import pingan.com.quarter_hour.R;
import pingan.com.quarter_hour.acyivity.login.LoginActivity;
import pingan.com.quarter_hour.acyivity.search.SearchaActivity;

/**
 * Created by mxn on 2016/12/13.
 * MenuListFragment
 */

public class MenuListFragment extends Fragment {


    @BindView(R.id.c_name)
    TextView cName;
    @BindView(R.id.c_sex)
    TextView cSex;
    Unbinder unbinder;
    private SimpleDraweeView img;
    private LSettingItem mSettingItemOne;
    private LSettingItem item_tow;
    private LSettingItem item_three;
    private LSettingItem item_moshi;
    private LSettingItem item_four;
    private Button item_shezhi;


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_menu, container, false);

        img = (SimpleDraweeView) view.findViewById(R.id.ivMenuUserProfilePhoto);
        mSettingItemOne = (LSettingItem)view.findViewById(R.id.item_one);
        item_tow = (LSettingItem)view.findViewById(R.id.item_tow);
        item_three = (LSettingItem)view.findViewById(R.id.item_three);
        item_four = (LSettingItem)view.findViewById(R.id.item_four);
        item_moshi = (LSettingItem)view.findViewById(R.id.item_moshi);
        item_shezhi =(Button)view.findViewById(R.id.shezhi);
        //点击事件
        initView();

        //设置图片
        init();
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    private void initView() {
        img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(),LoginActivity.class);
                startActivity(intent);
            }
        });

        //搜索
        item_three.setmOnLSettingItemClick(new LSettingItem.OnLSettingItemClick() {
            @Override
            public void click(boolean isChecked) {
                Intent intent1 = new Intent(getActivity(),SearchaActivity.class);
                startActivity(intent1);
            }
        });

        //设置
        item_shezhi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent2 = new Intent(getActivity(),InstallActivity.class);
                startActivity(intent2);
            }
        });

        //消息通知
        item_four.setmOnLSettingItemClick(new LSettingItem.OnLSettingItemClick() {
            @Override
            public void click(boolean isChecked) {
                Intent intent3 = new Intent(getActivity(),MessageActivity.class);
                startActivity(intent3);
            }
        });
    }

    private void init() {
        Uri uri = Uri.parse("http://a0.att.hudong.com/40/19/01300000870086129301191690908.jpg");
        img.setImageURI(uri);
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

}
